import React from "react";

const AuthRouter = (props) => {
    // 判断当前跳转路由是否需要登录认证
    if(props.auth)
    {
        // 从cookie里获取登录信息
        let business = React.Cookies.load('business') ? React.Cookies.load('business') : {};

        // 判断登录信息是否为空
        if(!business || JSON.stringify(business) === '{}')
        {
            return (
                <>
                    <React.Router.Navigate to='/business/base/login' />
                </>
            )
        }else{
            return <>{props.component}</>;
        }

    }else{
        return (
            <>
                {props.component}
            </>
        )
    }
}

export default AuthRouter;